<?php
/**
 * GioCMS
 * 
 * LICENSE
 *
 * This source file is subject to the GNU GENERAL PUBLIC LICENSE Version 2 
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.gnu.org/licenses/gpl-2.0.txt
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@ninhgio.com so we can send you a copy immediately.
 * 
 * @copyright	Copyright (c) 2010-2011 GioCMS (http://cms.ninhgio.com)
 * @license		http://www.gnu.org/licenses/gpl-2.0.txt GNU GENERAL PUBLIC LICENSE Version 2
 * @author		NinhGio - ninhgio@gmail.com
 * @since		1.0
 * @version		$Id: Captcha.php 97 2011-04-10 17:39:27Z ninhgio@gmail.com $
 */

class Modules_Core_Services_Captcha
{
	public static function get($option = array())
	{
		$option = array(
			'img_dir' 		=> isset($option['img_dir']) ? $option['img_dir'] : null,
			'img_url' 		=> isset($option['img_url']) ? $option['img_url'] : null,
			'font' 			=> isset($option['font']) ? $option['font'] : null,
			'expiration' 	=> isset($option['expiration']) ? $option['expiration'] : 60,
			'dot_level' 	=> isset($option['dot_level']) ? $option['dot_level'] : 10,
			'line_level' 	=> isset($option['line_level']) ? $option['line_level'] : 5,
			'width' 		=> isset($option['width']) ? $option['width'] : 100,
			'height' 		=> isset($option['height']) ? $option['height'] : 50,
		);
		$captcha = new Gio_Captcha_Image();
		$captcha->setImgDir($option['img_dir']);
		$captcha->setImgUrl($option['img_url']);
		$captcha->setFont($option['font']);
		$captcha->setExpiration($option['expiration']);
		$captcha->setDotNoiseLevel($option['dot_level']);
		$captcha->setLineNoiseLevel($option['line_level']);
		$captcha->setWidth($option['width']);
		$captcha->setHeight($option['height']);
		$captcha->generate();
		return $captcha->render();
	}
	
	public static function validate()
	{
		
	}
}